package sctu.edu.java.year2016.team06.yuweimei.day20160605.chapter12_3;

/**编写程序，实现当用户输入姓名和密码时，将每一个姓名和密码加在文件中。
 * Created by asus on 2016/6/5.
 */

import java.io.*;
import java.util.Scanner;
public class ShengFen {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入你的名字：");
        String name = scan.nextLine();
        System.out.println("请输入你的密码：");
        int passord = scan.nextInt();
        File file = new File("D:\\user.txt");
        try {
            file.createNewFile();
        } catch (IOException e) {
            e.printStackTrace();
        }
        String news = name;
       int news2 = passord;
        FileWriter s1 = null;
        try {
            s1 = new FileWriter(file);
            s1.write(news);
            s1.write(news2);
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println(s1);


    }
}
